<template>
	<view class="container-box">
		<view class="camera-box">
			<cover-view class="head">
				<cover-image @tap="outClass" src="http://img.curiousmore.com/tmp/wx2f4eaeb7b745ba4e.o6zAJs2bel8UMMafp-gtnT7OfHzo.XdCb4wCjvrP1df529ce1af8ca4118234c0e4a8da7b57.png"></cover-image>
			</cover-view>
			<webrtc-room id="myroom" :roomID="roomID" :userID="userID" :userSig="userSig" :sdkAppID="sdkAppID" :privateMapKey="privateMapKey"
			 :template="template" :beauty="3" :muted="false" :debug="false" @RoomEvent="onRoomEvent" :enableIM="false"
			 @IMEvent="onIMEvent">
				<cover-view v-if="isClass == true" slot="bigsmall" style='height:100%;width:100%;position:absolute;'>
					<cover-view class="video_top">
						<cover-view class="video_top_left">
							<cover-view class="zhuangtai_box">
								<cover-view>上课中</cover-view>
								<cover-image src="/static/jingyou/inclass.png" mode=""></cover-image>
							</cover-view>
							<cover-view>剩余时间</cover-view>
							<cover-view>{{classTime}}</cover-view>
						</cover-view>
						<cover-view class="video_top_mid">
							<cover-view>{{masterinfo.nick_name}}老师的课堂</cover-view>
							<cover-view class="cover-view1">
								第四节 {{classData.title}}
							</cover-view>
						</cover-view>
						<cover-image @tap="outClass" class="video_top_right" src="/static/jingyou/outClass.png" mode=""></cover-image>
					</cover-view>
					<cover-view id="text_box">
						<cover-view class="text_item" v-for="(item,index) in meTextMsg" :key='index'>
							<cover-view v-if="item.fromAccount==userID" >
								<cover-view class="text_word" v-if="item.type=='text'">
									{{item.user_name}}:{{item.text}}
								</cover-view>
								<cover-view v-else-if="item.type=='gift'">
									你给{{masterinfo.user_name}}送了礼物
								</cover-view>
							</cover-view>
							<cover-view v-else>
								<cover-view class="text_word" v-if="item.type=='text'">
									{{masterinfo.user_name}}:{{item.text}}
								</cover-view>
								<cover-view v-else-if="item.type=='gift'">
									{{masterinfo.user_name}}给你送了礼物
								</cover-view>
							</cover-view>
						</cover-view>
					</cover-view>
					<cover-view class="video_bottom">
						<cover-view class="video_bottom_left_box">
							<cover-image @tap="inputText('text')" class="video_bottom_left" src="/static/jingyou/xinxi.png" mode=""></cover-image>
							<cover-view v-if="isTeacher==true" @tap="inputText('Keyword')" class="guanjianzi">
								关键字
							</cover-view>
						</cover-view>
						<cover-image @tap="showGift" class="video_bottom_right" src="/static/jingyou/giftimg.png" mode=""></cover-image>
					</cover-view>
					<gift :isshowGift='isshowGift' :cat_coin='myInfo.cat_coin' :pay_id='userID' :payment_id='selToID' @hideAll='hideAll'></gift>
					<mask :isShowMask='isShowMask' @closeMask='closeMask'></mask>
					<keyFrame @toComment="onSendMsg" :isShow="iskeyFrame" @loseFocus="loseFocus"></keyFrame>
				</cover-view>
			</webrtc-room>
		</view>
	</view>
</template>

<script>
	import webim from '../../../common/webim_wx.min.js'
	import gift from '../../../components/gift.vue'
	import mask from '../../../components/mask.vue'
	import keyFrame from '../../../components/keyFrame.vue'
	import {
	    mapState,
		mapMutations
	} from 'vuex'
	export default {
		computed: mapState(['hascall']),
		components: {
			gift,
			mask,
			keyFrame
		},
		data() {
			return {
				//...
				roomID: '', // [必选]房间号，可以由您的服务指定
				userID: uni.getStorageSync('user_id'), // [必选]用户 ID，可以由您的服务指定，或者使用小程序的 openid
				userSig: uni.getStorageSync('user_sign'), // [必选]身份签名，需要从自行搭建的签名服务获取
				sdkAppID: '1400255047', // [必选]开通实时音视频服务创建应用后分配的 sdkAppID
				template: 'bigsmall', // [必选]标识组件使用的界面模版，组件内置了 bigsmall，float，grid 三种布局
				privateMapKey: '', // 房间权限 key，需要从自行搭建的签名服务获取
				// 如果您没有在【控制台】>【实时音视频】>【您的应用名称】>【帐号信息】中启用权限密钥，可不用填
				beauty: 9, // 美颜指数，取值 0 - 9，数值越大效果越明显
				muted: false, // true 静音 false 不静音
				debug: false, // true 打印推流 debug 信息 fales 不打印推流 debug 信息
				enableIM: true, // 是否启用IM
				// 其他配置参数可查看 API 文档
				webrtcroom: '',
				loginInfo: '',
				friendHeadUrl: '',
				selType: 'C2C',
				videoData: '', //自定义数据
				isClass: true, //是否是上课
				masterinfo: '', //老师信息
				classData: '', //课程信息
				isshowGift: false,
				isShowMask: false,
				iskeyFrame: false, //聊天输入框
				pay_id: '', //
				isTeacher: '', //是否是教师端
				h: 0,
				s: 0,
				m: 0,
				meesageTime: '00:04', //通话时间
				time: 0,
				nowTime: '',
				classTime: '', //本节课剩余时间
				classend:'',//课程结束计时
				Messagetimer:'',
				meTextMsg:[],//聊天内容
				newsText:'',//输入框内容
				selToID:'',//对面id
			}
		},
		onLoad(option) {
			// console.log(option, '路径数据')
			var me=this
			this.videoData = JSON.parse(option.data)
			this.roomID = this.videoData.roomId
			if(this.videoData.roomId==this.userID){//是我发起的视频
				this.selToID=this.videoData.userId
			}else{
				this.selToID=this.videoData.roomId
			}
			if (this.videoData.messageType == 'gotoclass') {
				this.isClass = true
				// console.log(this.videoData.appointment_id, '课节id')
				this.getClassData()
				// this.countdown()
				console.log(this.selToID,'聊天对象')
				this.Messagetimer= setInterval(function(){
					var newMsgList=uni.getStorageSync('newMessage')
					if(newMsgList!=undefined){
							if (newMsgList.fromAccount == me.selToID) { //为当前聊天对象的消息
								me.meTextMsg.push(newMsgList)
								console.log(me.meTextMsg,'消息列表')
							}
						uni.removeStorageSync('newMessage')
						var selSess = webim.MsgStore.sessByTypeId(this.selType, this.item);
						webim.setAutoRead(selSess, true, true);
						//消息已读上报，以及设置会话自动已读标记
					}
				},1000)
			} else if (this.videoData.messageType == 'normal') {
				this.isClass = false
				this.checkTime()
			}
			// console.log(this.videoData, '视频数据')

			this.webrtcroom = this.$mp.page.selectComponent('#myroom');
			if (this.webrtcroom !== '') {
				this.webrtcroom.start();
			}
			this.loginInfo = uni.getStorageSync('loginInfo')
			this.myInfo = uni.getStorageSync('user_info')
			this.start()
			// this.isClass = true
			
			this.isCalling()
		},
		onUnload() {
			clearInterval(this.time);
			clearInterval(this.nowTime)
			clearTimeout(this.classend)
			clearInterval(this.Messagetimer)
			// console.log(this.meesageTime, '通话时间')
		},
		onShow() {
			// this.clickGungun()
		},
		methods: {
			...mapMutations(['isNoCall','isCalling']),
			// 标签通过 onRoomEvent 返回内部事件
			onRoomEvent: function(e) {
				switch (e.detail.tag) {
					case 'error':
						{
							//发生错误
							var code = e.detail.code;
							var detail = e.detail.detail;
							break;
						}
				}
			},
			// 通过 onIMEvent 返回 IM 消息事件，如果 enableIM 已关闭，则可以忽略 onIMEvent
			onIMEvent: function(e) {
				switch (e.detail.tag) {
					case 'big_group_msg_notify':
						//收到群组消息
						console.debug(e.detail.detail)
						break;
					case 'login_event':
						//登录事件通知
						console.debug(e.detail.detail)
						break;
					case 'connection_event':
						//连接状态事件
						console.debug(e.detail.detail)
						break;
					case 'join_group_event':
						//进群事件通知
						console.debug(e.detail.detail)
						break;
				}
			},
			sendCustomMsg(type) { //发送自定义消息
				if (type == 'gift') {
					var data = uni.getStorageSync('giftData')
				} else if (type == 'guaduan') {
					var data = {
						roomId: this.roomID,
						type: 'videoHangupMessage',
						userId: this.videoData.userId,
						meesageTime: this.meesageTime,
					}
				}

				var me = this
				data = JSON.stringify(data)
				// console.log(data, '数据')
				var desc = "";
				var ext = "";

				var msgLen = webim.Tool.getStrBytes(data);
				var selToID = this.selToID
				console.log(selToID,'对象id')


				if (data.length < 1) {
					console.log("发送的消息不能为空!");
					return;
				}
				var maxLen, errInfo;
				if (this.selType == webim.SESSION_TYPE.C2C) {
					maxLen = webim.MSG_MAX_LENGTH.C2C;
					errInfo = "消息长度超出限制(最多" + Math.round(maxLen / 3) + "汉字)";
				} else {
					maxLen = webim.MSG_MAX_LENGTH.GROUP;
					errInfo = "消息长度超出限制(最多" + Math.round(maxLen / 3) + "汉字)";
				}
				if (msgLen > maxLen) {
					console.log(errInfo);
					return;
				}
				// console.log(selSess);
				// console.log(111);
				if (!selSess) {
					var selSess = new webim.Session(this.selType, selToID, selToID, this.friendHeadUrl, Math.round(new Date().getTime() /
						1000));
				}
				var msg = new webim.Msg(selSess, true, -1, -1, -1, this.loginInfo.identifier, 0, this.loginInfo.identifierNick);
				var custom_obj = new webim.Msg.Elem.Custom(data, desc, ext);
				msg.addCustom(custom_obj);
				//调用发送消息接口
				msg.sending = 1;
				webim.sendMsg(msg, function(resp) {
					// addMsg(msg);
					// $("#id_" + msg.random).find(".spinner").remove();
					// if (selType == webim.SESSION_TYPE.C2C) {
					//     //私聊时，在聊天窗口手动添加一条发的消息，群聊时，长轮询接口会返回自己发的消息
					//     addMsg(msg);
					// }
					// $('#edit_custom_msg_dialog').modal('hide');
					var msgData = {
						content: JSON.parse(data),
						fromAccount: '' + uni.getStorageSync('user_id'),
					}
					// me.meTextMsg.push(msgData)

					if (type == 'gift') {
						msgData.type = 'gift'
						uni.removeStorageSync('giftData')
					}
				}, function(err) {
					console.log(err.ErrorInfo);
				});
			},
			//发送消息判断文本方法，
			//初步判断处理数据是否合格，文本合格执行handleMsgSend()将msgContent(消息文本)为参传递至handleMsgSend()，在handleMsgSend()中上传至腾讯云，
			onSendMsg(content) {
				this.newsText = content
				if (this.newsText == "") {
					return
				}
				var _this = this
				var selToID = this.selToID
				// console.log(this.item +'用户聊天ID')
				var selType = this.selType; //当前聊天类型
				console.log(selToID, '聊天id')
				if (!selToID) {
					console.log("你还没有选中好友或者群组，暂不能聊天");
					return;
				}
				//获取消息内容
				var msgContent = this.newsText; //聊天内容
				var msgLen = webim.Tool.getStrBytes(msgContent) //聊天发送消息所占字符长度;
				if (msgContent.length < 1) {
					console.log("发送的消息不能为空!");
					return;
				}
				var maxLen, errInfo;
				if (selType == webim.SESSION_TYPE.C2C) {
					maxLen = webim.MSG_MAX_LENGTH.C2C;
					errInfo = "消息长度超出限制(最多" + Math.round(maxLen / 3) + "汉字)";
					// console.log('进入1' + maxLen + msgContent)
				} else {
					// console.log('进入2')
					maxLen = webim.MSG_MAX_LENGTH.GROUP;
					errInfo = "消息长度超出限制(最多" + Math.round(maxLen / 3) + "汉字)";
				}
				if (msgLen > maxLen) {
					// console.log('进入3')
					console.log(errInfo);
					return;
				}
				//发消息处理
				this.handleMsgSend(msgContent);
			},
			//发送消息判断文本方法

			// 上传发送消息文本方法
			handleMsgSend(msgContent) {
				var AdminAcount = 'qwe101'; //管理员账号？
				// var selType = webim.SESSION_TYPE.C2C; //当前聊天类型
				var selType = webim.SESSION_TYPE.GROUP; //群聊类型
				if (this.selType == 'C2C') {
					selType = webim.SESSION_TYPE.C2C
				} else {
					selType = webim.SESSION_TYPE.GROUP
				}
				var selToID = this.selToID; //当前选中聊天id（当聊天类型为私聊时，该值为好友帐号，否则为群号）
				var selSess = null; //当前聊天会话对象
				var recentSessMap = {}; //保存最近会话列表
				var reqRecentSessCount = 50; //每次请求的最近会话条数，业务可以自定义
				var isPeerRead = 1; //是否需要支持APP端已读回执的功能,默认为0。是：1，否：0。
				//默认好友头像
				var friendHeadUrl = 'img/friend.jpg'; //仅demo使用，用于没有设置过头像的好友
				//默认群头像
				var groupHeadUrl = 'img/group.jpg'; //仅demo使用，用于没有设置过群头像的情况
				//存放c2c或者群信息（c2c用户：c2c用户id，昵称，头像；群：群id，群名称，群头像）
				var infoMap = {}; //初始化时，可以先拉取我的好友和我的群组信息
				var maxNameLen = 12; //我的好友或群组列表中名称显示最大长度，仅demo用得到
				var reqMsgCount = 15; //每次请求的历史消息(c2c获取群)条数，仅demo用得到
				var pageSize = 15; //表格的每页条数，bootstrap table 分页时用到
				var totalCount = 200; //每次接口请求的条数，bootstrap table 分页时用到
				var emotionFlag = false; //是否打开过表情选择框
				var curPlayAudio = null; //当前正在播放的audio对象
				var getPrePageC2CHistroyMsgInfoMap = {}; //保留下一次拉取好友历史消息的信息
				var getPrePageGroupHistroyMsgInfoMap = {}; //保留下一次拉取群历史消息的信息
				var defaultSelGroupId = null; //登录默认选中的群id，选填，仅demo用得到
				if (!selSess) {
					var selSess = new webim.Session(selType, selToID, selToID, this.friendHeadUrl, Math.round(new Date().getTime() /
						1000));
				}
				var isSend = true; //是否为自己发送
				var seq = -1; //消息序列，-1表示sdk自动生成，用于去重
				var random = Math.round(Math.random() * 4294967296); //消息随机数，用于去重
				var msgTime = Math.round(new Date().getTime() / 1000); //消息时间戳
				var subType; //消息子类型

				if (this.selType == webim.SESSION_TYPE.C2C) {
					subType = webim.C2C_MSG_SUB_TYPE.COMMON;
				} else {
					//webim.GROUP_MSG_SUB_TYPE.COMMON-普通消息,
					//webim.GROUP_MSG_SUB_TYPE.LOVEMSG-点赞消息，优先级最低
					//webim.GROUP_MSG_SUB_TYPE.TIP-提示消息(不支持发送，用于区分群消息子类型)，
					//webim.GROUP_MSG_SUB_TYPE.REDPACKET-红包消息，优先级最高
					subType = webim.GROUP_MSG_SUB_TYPE.COMMON;
				}
				var msg = new webim.Msg(selSess, isSend, seq, random, msgTime, this.myInfo.user_id, subType, this.myInfo.nick_name);

				var text_obj, face_obj, tmsg, emotionIndex, emotion, restMsgIndex;
				//解析文本和表情
				var expr = /\[[^[\]]{1,3}\]/mg;
				var emotions = msgContent.match(expr);
				var _this = this
				if (!emotions || emotions.length < 1) {
					text_obj = new webim.Msg.Elem.Text(msgContent);
					msg.addText(text_obj);
				} else {
					for (var i = 0; i < emotions.length; i++) {
						tmsg = msgContent.substring(0, msgContent.indexOf(emotions[i]));
						if (tmsg) {
							text_obj = new webim.Msg.Elem.Text(tmsg);
							msg.addText(text_obj);
						}
						emotionIndex = webim.EmotionDataIndexs[emotions[i]];
						emotion = webim.Emotions[emotionIndex];

						if (emotion) {
							face_obj = new webim.Msg.Elem.Face(emotionIndex, emotions[i]);
							msg.addFace(face_obj);
						} else {
							text_obj = new webim.Msg.Elem.Text(emotions[i]);
							msg.addText(text_obj);
						}
						restMsgIndex = msgContent.indexOf(emotions[i]) + emotions[i].length;
						msgContent = msgContent.substring(restMsgIndex);
					}
					if (msgContent) {
						text_obj = new webim.Msg.Elem.Text(msgContent);
						msg.addText(text_obj);
					}
				}

				msg.PushInfo = {
					"PushFlag": 0,
					"Desc": '测试离线推送内容', //离线推送内容
					"Ext": '测试离线推送透传内容', //离线推送透传内容
					"AndroidInfo": {
						"Sound": "android.mp3" //离线推送声音文件路径。
					},
					"ApnsInfo": {
						"Sound": "apns.mp3", //离线推送声音文件路径。
						"BadgeMode": 1
					}
				};

				msg.PushInfoBoolean = false; //是否开启离线推送push同步
				msg.sending = 1;
				msg.originContent = msgContent;
				// addMsg(msg);
				// $("#send_msg_text").val('');
				// turnoffFaces_box();

				webim.sendMsg(msg, function(resp) { //发送消息方法
					//发送成功，把sending清理
					// 										var a = ;
					// 										uni.pageScrollTo({
					// 											scrollTop: a.height,
					// 											duration: 300
					// 										});
					// _this.getLastC2CHistoryMsgs()
					var date = new Date().getTime(); //当前时间
					var obj = {
						text: _this.newsText,
						time: _this.timeProcessing.formatDate(date),
						fromAccount: _this.userID,
						type: 'text',
						user_name:uni.getStorageSync('nick_name')
					}
					_this.meTextMsg.push(obj)
					console.log(_this.meTextMsg,'消息列表')
					_this.newsText = ''
					_this.clickGungun()
					// $("#id_" + msg.random).find(".spinner").remove();
					// webim.Tool.setCookie("tmpmsg_" + selToID, '', 0);
				}, function(err) {
					//console.log(err.ErrorInfo);
					//提示重发
					console.log(err)
					// 					uni.showToast({
					// 						title: err.ErrorInfo,
					// 						icon: 'none'
					// 					})
					// this.showReSend(msg);
				});
			},
			// 上传发送消息文本方法
			outClass() { //退出视频提示
				var me = this
				uni.showModal({
					title: '提示',
					content: '确定要退出视频吗',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
							me.getClass()
							me.isNoCall()
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				})
			},
			getClass() { //挂断视频
				var me = this;
				if (this.videoData.messageType == 'normal') {
					var type = 'video'
				} else if (this.videoData.messageType == 'gotoclass') {
					var type = 'class'
				}
				var data = {
					id: this.videoData.video_id,
					type: type,
					status: 2
				}
				this.myAjaxNewPost({
					model: 'user',
					controllerName: 'videoDuration',
					actionName: 'insert',
					data: data,
					successBack: function(res) {
						console.log(res, '挂断视频')
						me.webrtcroom.stop()
						me.sendCustomMsg('guaduan')
						// this.sendC2CCustomMsg(userID,data)
						uni.navigateBack({
							delta: 2
						})
						uni.showToast({
							title: '已挂断',
							icon: 'none'
						})
						clearInterval(me.timer)
					}
				})
			},
			getClassData() { //获取课程信息
				var me = this;
				var data = {
					id: this.videoData.appointment_id,
				}
				this.myAjaxNew({
					model: 'user',
					controllerName: 'userAppointment',
					actionName: 'queryListPage',
					data: data,
					successBack: function(res) {
						console.log(res, '课程资料')
						if (res.data.data.length != 0) {
							me.masterinfo = res.data.data[0].map.masterinfo;
							if (me.masterinfo.user_id == uni.getStorageSync('user_id')) {
								me.isTeacher = true
								me.selToID = me.userinfo.user_id
							} else {
								me.selToID = me.masterinfo.user_id
							}
							me.classData = res.data.data[0]
							me.class_endtime = res.data.data[0].end_time
							me.countdown()
						}
					}
				})
			},
			closeMask() {
				this.isShowMask = false;
				this.isshowGift = false;
				this.iskeyFrame = false;
			},
			showGift() {
				this.iskeyFrame = false;
				this.isshowGift = true;
				this.isShowMask = true;
			},
			loseFocus() {
				this.iskeyFrame = false
			},
			inputText(type) {
				this.iskeyFrame = true;
			},
			// 			toComment() {
			// 				if (type == 'keyWord') {
			// 					var data = {
			// 
			// 					}
			// 				}
			// 			},
			timer() { //定义计时函数
				this.s = this.s + 1; //秒
				if (this.s >= 60) {
					this.s = 0;
					this.m = this.m + 1; //分钟
				}
				if (this.m >= 60) {
					this.m = 0;
					this.h = this.h + 1; //小时
				}
				if (this.h == 0) {
					this.meesageTime = this.toDub(this.m) + ":" + this.toDub(this.s) + ""
				} else {
					this.meesageTime = this.toDub(this.h) + ":" + this.toDub(this.m) + ":" + this.toDub(this.s) + "" /*+this.toDubms(this.ms)+"毫秒"*/ ;
					// document.getElementById('mytime').innerHTML=h+"时"+m+"分"+s+"秒"+ms+"毫秒";
				}
				// console.log(this.meesageTime)
			},
			toDub(n) { //补0操作
				if (n < 10) {
					return "0" + n;
				} else {
					return "" + n;
				}
			},
			start() { //开始计时，计算通话时间
				this.time = setInterval(this.timer, 1000);
			},
			checkTime() { //
				var end_time = uni.getStorageSync('end_time')
				var remind_time = this.reduceTwoS(end_time)
				console.log(remind_time, '提醒时间')

				end_time = end_time.replace(/-/g, '/');
				remind_time = remind_time.replace(/-/g, '/');

				var timestamp = new Date(end_time).getTime(); //视频可用结束时间戳
				var remindTimestamp = new Date(end_time).getTime(); //提醒可用时间戳
				this.nowTime = setInterval(function() {
					var nowTimestamp = parseInt(new Date().getTime() / 1000); //当前时间戳
					if (nowTimestamp == remindTimestamp) {
						uni.showModal({
							title: '提示',
							content: '当前视频剩余时间少于10分钟，请及时充值',
							success: function(res) {
								if (res.confirm) {
									console.log('用户点击确定');
								} else if (res.cancel) {
									console.log('用户点击取消');
								}
							}
						})
					}
					if (nowTimestamp == timestamp) {

						uni.showModal({
							title: '提示',
							content: '猫币已耗完，视频服务已停止',
							success: function(res) {
								if (res.confirm) {
									console.log('用户点击确定');
								} else if (res.cancel) {
									console.log('用户点击取消');
								}
							}
						})
						this.getClass()
					}
				}, 1000);

			},
			reduceTwoS(dateStr) { //获取提前10分钟的时间
				var dt = new Date(dateStr.replace(/-/, "/")); //将传入的日期格式的字符串转换为date对象 兼容ie
				// var dt=new Date(dateStr);//将传入的日期格式的字符串转换为date对象 非ie
				var ndt = new Date(dt.getTime() - 600000); //将转换之后的时间减去10分钟
				var result = this.toDub(parseInt(ndt.getFullYear())) + '-' + this.toDub(parseInt(ndt.getMonth() + 1)) + '-' + this.toDub(
						parseInt(ndt.getDay())) + ' ' + this.toDub(parseInt(ndt.getHours())) + ':' + this.toDub(parseInt(ndt.getMinutes())) +
					':' + this.toDub(parseInt(ndt.getSeconds()))
				return result;
			},
			countdown() {
				const end = Date.parse(new Date(this.class_endtime))
				const now = Date.parse(new Date())
				const msec = end - now
				// let day = parseInt(msec / 1000 / 60 / 60 / 24)
				let hr = parseInt(msec / 1000 / 60 / 60 % 24)
				let min = parseInt(msec / 1000 / 60 % 60)
				let sec = parseInt(msec / 1000 % 60)
				// console.log(msec,end,now,'时间戳')
				// console.log(this.class_endtime,'结束时间')
				// this.day = day
				hr = hr > 9 ? hr : '0' + hr
				min = min > 9 ? min : '0' + min
				sec = sec > 9 ? sec : '0' + sec
				this.classTime = hr + ':' + min + ':' + sec
				const that = this
				if (msec > 0) {
					this.classend=setTimeout(function() {
						that.countdown()
					}, 1000)
				} else {
					uni.showModal({
						title: '提示',
						content: '本节课时间到啦，快去预约下节课吧',
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					})
					this.getClass()
				}
			},
			clickGungun() { //滚动到底部
				let view = uni.createSelectorQuery().in(this).select("#text_box");
				view.fields({
					size: true,
					rect: true,
					scrollOffset: true
				}, data => {
					console.log(data, '标签数据')

					uni.pageScrollTo({
						scrollTop: data.height,
						duration: 0,
					})
				}).exec();
			},
			hideAll() { //礼物
				this.isShowMask = false
				this.isshowGift = false
				if (uni.getStorageSync('giftData') != undefined && uni.getStorageSync('giftData') != "") {
					this.sendCustomMsg('gift')
				}
				console.log('隐藏')
			},
		}
	}
</script>

<style scoped>
	.head {
		height: 11%;
		background: #FFFFFF;
	}

	.head cover-image {
		width: 10px;
		height: 18px;
		padding-top: 10%;
		padding-left: 12px;
	}

	.container-box {
		/* background-image: url(https://mc.qcloudimg.com/static/img/7da57e0050d308e2e1b1e31afbc42929/bg.png); */
		background-color: #fff;
		background-repeat: no-repeat;
		background-size: cover;
		height: 100%;
		overflow: hidden;
	}

	.camera-box {
		width: 100%;
		height: 100%;
	}

	.video_top {
		display: flex;
		justify-content: space-between;
		padding-right: 12px;
		position: absolute;
		/* top: 12%; */
		box-sizing: border-box;
		width: 100%;
		align-items: center;
	}

	.video_top_left {
		width: 69px;
		height: 49px;
		/* background: #000000;
			opacity: 0.3; */
		background: rgba(0, 0, 0, 0.3);
		border-radius: 0px 24px 24px 0px;
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		color: #FFFFFF;
		font-size: 10px;
		padding-left: 5px;
		padding-top: 10px;
	}

	.video_top_left cover-image {
		width: 17px;
		height: 4px;
	}

	.zhuangtai_box {
		display: flex;
		align-items: center;

	}

	.video_top_mid {
		width: 192px;
		height: 49px;
		border-radius: 25px;
		background: rgba(0, 0, 0, 0.3);
		color: #FFFFFF;
		font-size: 14px;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: space-around;
	}

	.text1 {
		font-size: 10px;
	}

	.video_top_right {
		width: 49px;
		height: 49px;
		margin-left: 25px;
	}

	.video_bottom {
		position: absolute;
		bottom: 100px;
		padding: 0 12px;
		width: 100%;
		display: flex;
		justify-content: space-between;
		box-sizing: border-box;
		flex-wrap: nowrap;
	}

	.video_bottom_left_box {
		display: flex;
	}

	.video_bottom_left {
		width: 46px;
		height: 46px;
		margin-right: 12px;
	}

	.guanjianzi {
		width: 46px;
		height: 46px;
		border-radius: 50%;
		background: rgba(0, 0, 0, 0.3);
		text-align: center;
		line-height: 46px;
		color: #FFFFFF;
		font-size: 13px;
	}

	.video_bottom_right {
		width: 46px;
		height: 46px;
	}

	#text_box {
		/* background: #FFFFFF; */
		height: 500upx;
		/* max-width: 600upx; */
		position: absolute;
		left: 0px;
		bottom: 300upx;
		padding-right: 10px;
		overflow-y: scroll;
	}

	.text_item {
		border-top-right-radius: 40%;
		border-bottom-right-radius: 40%;
		padding: 20upx 10upx;
		background: rgba(0, 0, 0, 0.3);
		display: flex;
		align-items: center;
		color: #FFFFFF;
		font-size: 24upx;
		max-width: 600upx;
		margin-bottom: 16upx;
	}

	.text_word {
		word-wrap: break-word;
		word-break: normal;
	}
</style>
